<h1 class="page-header">
    <small>编辑店铺信息</small>
</h1>
<hr/>
<div class="panel panel-inverse" data-sortable-id="form-stuff-1">
    <div class="panel-heading">
        <h4 class="panel-title">店铺信息</h4>
    </div>
    <div class="panel-body">
        <form class="form-horizontal" id="storeForm" name="storeForm" action="" method="post">
            <input type="hidden" id="storeId" name="storeId" class="form-control" value="${store.id}">
            <div class="form-group">
                <label class="col-md-3 control-label"><span class="requiredstar">* </span>店铺名称</label>
                <div class="col-md-3">
                    <input type="text" id="storeName" name="storeName" class="form-control" placeholder="店铺名称" value="${store.name}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label"><span class="requiredstar">* </span>默认店铺：</label>
                <div class="col-md-3">
                    <select class="form-control" name="isDefault" id="isDefault">
                        <option value="N" <#if store.isDefault == 'N'>selected</#if>>否</option>
                        <option value="Y" <#if store.isDefault == 'Y'>selected</#if>>是</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">联系人姓名：</label>
                <div class="col-md-3">
                    <input type="text"  id="ContactName" name="ContactName" class="form-control" placeholder="联系人姓名" value="${store.contact}">
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-3 control-label">联系电话：</label>
                <div class="col-md-3">
                    <input type="text" id="ContactPhone" name="ContactPhone" class="form-control" placeholder="联系电话" value="${store.phone}">
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-3 control-label">店铺经度：</label>
                <div class="col-md-3">
                    <input type="text" id="latitude" class="form-control" name="latitude" placeholder="店铺经度，用于计算距离" value="${store.latitude}" maxlength="100" >
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-3 control-label">店铺纬度：</label>
                <div class="col-md-3">
                    <input type="text" id="longitude" class="form-control" name="longitude" placeholder="店铺纬度，用于计算距离" value="${store.longitude}" maxlength="100" >
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-3 control-label">店铺地址：</label>
                <div class="col-md-5">
                    <input type="text" id="address" class="form-control" name="address" placeholder="店铺地址" value="${store.address}" maxlength=100" >
                </div>
            </div>
    
            <div class="form-group">
                <label class="col-md-3 control-label">营业时间：</label>
                <div class="col-md-5">
                    <input type="text" id="hours" class="form-control" name="hours" placeholder="营业时间" value="${store.hours}" maxlength="100" >
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-3 control-label">备注信息</label>
                <div class="col-md-5">
                    <textarea rows="5" class="form-control" id="storeDesc" name="storeDesc" maxlength="500" placeholder="备注信息">${store.description}</textarea>
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-3 control-label"></label>
                <div class="col-md-9">
                    <button type="button" id="submitButton" class="btn btn-sm btn-success">提交</button>
                    <button type="button" class="btn btn-sm btn-danger"
                            onclick="getData('${rc.contextPath}/backend/store/queryList','displayArea')">返回
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="application/javascript">
    $(function () {
        $('#submitButton').click(function () {
            $('#storeForm').submit();
        })
        $('#storeForm').validate({
            rules: {
                storeName: {
                    required: true,
                    byteRangeLength: [2, 20]
                }
            },
            messages: {
                storeName: {
                    required:"填写店铺名称！",
                    rangelength: "长度为2-20的字母\\数字\\下划线\\点"
                }
            },
            errorPlacement: function (error, element) {
                error.appendTo(element.parent());
            },
            submitHandler: function () {
                postDataByFormParams('${rc.contextPath}/backend/store/save', 'displayArea', 'storeForm');
            }
        })
    })
</script>
